package Test;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class Demo1 {

    Socket socket = null;

    public Demo1(String s, int p) throws IOException {
        socket = new Socket(s, p);
    }

    public void start() {
        Scanner sc = new Scanner(System.in);

        try (InputStream inputStream = socket.getInputStream();
             OutputStream outputStream = socket.getOutputStream()) {

            Scanner scanner = new Scanner(inputStream);
            PrintWriter printWriter = new PrintWriter(outputStream);

            while (true) {

                String s1 = sc.next();
                printWriter.println(s1);
                printWriter.flush();
                String s2 = scanner.next();
                System.out.println(s2);


            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }

    public static void main(String[] args) throws IOException {
        Demo1 d = new Demo1("127.0.0.1", 6633);
        d.start();
    }
}
